import { createApp } from 'vue'

import App from './App.vue'
import router from './router'
import * as Sentry from "@sentry/vue";

const app = createApp(App)

// 根据环境变量决定是否启用 Sentry
const enableSentry = import.meta.env.VITE_ENABLE_SENTRY === 'true' || import.meta.env.PROD

if (enableSentry) {
  Sentry.init({
    app,
    dsn: "https://2284d7af4f67e947b348fcc83b1987bc@o4510022581354496.ingest.de.sentry.io/4510022587318352",
    // Setting this option to true will send default PII data to Sentry.
    // For example, automatic IP address collection on events
    sendDefaultPii: true,
    integrations: [
      Sentry.replayIntegration()
    ],
    // Session Replay
    replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
    replaysOnErrorSampleRate: 1.0 // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
  });
  console.log('Sentry initialized for', import.meta.env.MODE, 'environment');
} else {
  console.log('Sentry is disabled in', import.meta.env.MODE, 'environment');
}
app.use(router)
app.mount('#app')
